package com.zy.Conterller;

import com.zy.vo.kucun.DeliveredVo;
import com.zy.vo.ResultVo;
import com.zy.pojo.Delivered;
import com.zy.pojo.Goods;
import com.zy.service.DeliveredService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;


@RestController
@RequestMapping("/delivered")
public class DeliveredController {
    @Resource
    private DeliveredService deliveredService;

    @GetMapping("/pagedeliveredlist/{pageNo}/{pageSize}")
    public ResultVo getdeliveredPageList(@PathVariable Integer pageNo, @PathVariable Integer pageSize, DeliveredVo deliveredVo){
        return ResultVo.success(deliveredService.getPageHousedList(pageNo,pageSize,deliveredVo));
    }
    @PostMapping("/deliveredaddRk")//
    public ResultVo getdeliveredAdd(@RequestBody Delivered delivered, Goods goods, HttpSession session){
        try{
            delivered.setDeliveredName(delivered.getDeliveredName());
            delivered.setDeliveredQuantity(delivered.getDeliveredQuantity());
            deliveredService.getDelivereDDel(delivered.getId());
            return ResultVo.success("退回出库商品成功!!!");
        }catch (Exception e){
            return ResultVo.fail("退回出库商品失败",e);//打印错误日志
        }

    }
    @PostMapping("/deliveredaddCK")
    public ResultVo getdeliveredAddc(@RequestBody Delivered delivered,HttpSession session) {

        try {
            deliveredService.getDelivereADDc(delivered);
            deliveredService.getDelivereDDel(delivered.getId());
            return ResultVo.success("出库商品成功!!!");
        } catch (Exception e) {
            return ResultVo.fail("出库商品失败", e);//打印错误日志
        }
    }

}
